//@require EnhancedJS.js
var 
    stat_types = {
		"combat_stat_add":["attack_rating","crit_chance","defense_rating","protection_rating","speed_rating"],
		"combat_stat_multiply":["damage_high","damage_low","defense_rating","max_hp"],
		"hp_heal_amount":[""],
		"stress_dmg_percent":[""],
		"stress_heal_percent":[""],
		"resolve_check_percent":[""],
		"resolve_xp_bonus_percent":[""],
		"resistance":["bleed","death_blow","debuff","disease","move","poison","stun","trap"],
		"stun_chance":[""],
		"poison_chance":[""],
		"bleed_chance":[""],
		"move_chance":[""],
		"debuff_chance":[""],
		"scouting_chance":[""],
		"remove_negative_quirk_chance":[""],
		"food_consumption_percent":[""],
		"starving_damage_percent":[""],
		"upgrade_discount":["armour","weapon"]
	},
	rule_types={
		'afflicted':'', 
		'always':'',
		'at_deaths_door':'',
		'firstroundonly':'',
		'hpabove':0.75,
		'hpbelow':0.25,
		'in_activity':['meditation','brothel'],
		'in_camp':'',
		'in_corridor':'',
		'in_dungeon':['crypts','warrens','weald','cove'],
		'in_rank':'',
		'lightabove':75,
		'lightbelow':25,
		'meleeonly':'',
		'monsterSize':2,
		'monsterType':['eldritch','unholy','man','beast'],
		'rangedonly':'',
		'stress_above':50,
		'virtued':'',
		'walking_backwards':''
	};
(function(window){
var 
	buff = function(stat_type,stat_sub_type,rule_type){
		return new buff.fn.init(stat_type,stat_sub_type,rule_type);
	};
buff.fn=buff.prototype={
	id : "",
	stat_type : "",
	stat_sub_type : "",
	amount : 0,
	rule_type : "",
	is_false_rule : false,
	rule_data : {
            "float" : 0,
            "string" : ""
    },
	init:function(stat_type,stat_sub_type,rule_type){
		this.stat_type=stat_type?stat_type:stat_types.property().random();
		this.stat_sub_type=stat_sub_type?stat_sub_type:stat_types[this.stat_type].random();
		this.rule_type = rule_type?rule_type:rule_types.property().random();
		this.rule_data["float"]=typeof rule_types[this.rule_type] == 'number'?rule_types[this.rule_type]:0;
		this.rule_data["string"]=typeof rule_types[this.rule_type] == 'object'?rule_types[this.rule_type].random():"";
		this.toString();
	},
	toString:function(){
		var json = {},arr=this.property();
		for (var i=0;i<arr.length ;i++ ){
			json[arr[i]]=this[arr[i]];
		}
		this.string = JSON.stringify(json);
	}
}
buff.fn.init.prototype = buff.fn;
window.buff=buff;
})(window)
